package T3;

import T2.Circle;
import T2.Point;

public class ColoredCircle extends Circle {
    private Color borderColor;// 圆的边界颜色
    private Color centerColor;// 圆的中心颜色

    public Color getBorderColor() {
        return borderColor;
    }

    public void setBorderColor(Color borderColor) {
        this.borderColor = borderColor;
    }

    public Color getCenterColor() {
        return centerColor;
    }

    public void setCenterColor(Color centerColor) {
        this.centerColor = centerColor;
    }

    public ColoredCircle(){
        this(new Point(),0,new Color(0, 0, 0),new Color(0,0,0));
    }
    public ColoredCircle(Point center,int radius){
        super(center,radius);//调用circle的带参构造
        this.borderColor = new Color(0,0,0);
        this.centerColor = new Color(0,0,0);
    }

    public ColoredCircle(Color borderColor, Color centerColor) {
        super();
        this.borderColor = borderColor;
        this.centerColor = centerColor;
    }

    public ColoredCircle(Point c, int r, Color borderColor, Color centerColor) {
        super(c, r);
        this.borderColor = borderColor;
        this.centerColor = centerColor;
    }

    public String describeRelation(Circle c) {
        int relationCode = super.relation(c);
        if (c instanceof ColoredCircle) {
//            多态中 向上转型通常是隐型的  向下转型是显型的
            //            向下转型通常用于访问子类特有的属性或方法
            ColoredCircle cc = (ColoredCircle) c;
            switch (relationCode) {
                case 0:
                    if (this.centerColor.equals(cc.getCenterColor()) && this.borderColor.equals(cc.getBorderColor())) {
                        return "同一带颜色的圆";
                    } else {
                        return "同心带颜色的圆";
                    }
                case 1:
                    return "同心圆";
                case 2:
                    return "相交";
                case 3:
                    return "分离";
                case 4:
                    return "包含";
                default:
                    return "未知关系";
            }
        } else {
            // 处理与普通圆的关系
            switch (relationCode) {
                case 0:
                    return "同一圆";
                case 1:
                    return "同心圆";
                case 2:
                    return "相交";
                case 3:
                    return "分离";
                case 4:
                    return "包含";
                default:
                    return "未知关系";
            }
        }
    }
}


